package.path = package.path..";"..lfs.currentdir().."/LuaSocket/?.lua"
package.cpath = package.cpath..";"..lfs.currentdir().."/LuaSocket/?.dll"
local socket = require("socket")
local socketurl = require("url")
local http = require("http")
local ltn12 = require("ltn12")
local test = require("socket.http")

net.log("测试Path: " .. tostring(package.path))
net.log("测试CPath: " .. tostring(package.cpath))

-- net.log("测试socket: ")
-- net.log("socket = " .. tostring(socket))
-- net.log("测试http: ")
-- net.log("http = " .. tostring(http))
net.log("测试socket.http: ")
net.log("socket.http = " .. tostring(test))

-- local function sendRequest(url, params)
--     -- 构建请求头
--     local headers = {
--         ["Content-Type"] = "application/x-www-form-urlencoded",
--         ["Content-Length"] = tostring(#params)
--     }

--     -- 发送POST请求
--     local response = {}
--     local result, status, headers = socket.http.request {
--         url = url,
--         method = "POST",
--         headers = headers,
--         source = ltn12.source.string(params),
--         sink = ltn12.sink.table(response)
--     }

--     -- 检查请求是否成功
--     if status == 200 then
--         local responseBody = table.concat(response)
--         -- 处理返回的响应
--         print("返回值: " .. responseBody)
--         return responseBody
--     else
--         -- 请求失败，处理错误
--         return "请求失败，状态码: " .. tostring(status)
--     end
-- end



-- local params = "ucid=eee6a222e156f7f1599e435a9e4163a8&name=TestDeathGun"
-- local url = "http://localhost:8079/api/player/login"

-- local result = sendRequest(url, params)
-- print(result)

-- net.log("测试Response: " .. tostring(result))